home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / MacTCP.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  24KB  |  823 lines

  1. /*
  2.      File:        MacTCP.h
  3.  
  4.      Contains:    TCP Manager Interfaces.
  5.  
  6.      Version:    Technology:    MacTCP 2.0.6
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __MACTCP__
  19. #define __MACTCP__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27. #ifndef __APPLETALK__
  28. #include <AppleTalk.h>
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT_SUPPORTED
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_ALIGN_SUPPORTED
  40. #pragma options align=mac68k
  41. #endif
  42.  
  43. #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
  44. /*
  45. Developer Notes:
  46.         0. This MacTCP header replaces what used to be defined in the following header files
  47.             MacTCPCommonTypes.h
  48.             GetMyIPAddr.h
  49.             MiscIPPB.h
  50.             TCPPB.h
  51.             UDPPB.h 
  52.             
  53.             When the various control calls are made to the ip driver, you must set up a 
  54.             NewRoutineDescriptor for every non-nil completion routine and/or notifyProc parameter.  
  55.             Otherwise, the 68K driver code, will not correctly call your routine.
  56.         1. For ipctlGetAddr Control calls, use NewGetIPIOCompletionProc
  57.             to set up a GetIPIOCompletionUPP universal procptr to pass as
  58.             the ioCompletion parameter.
  59.         2. For the ipctlEchoICMP and ipctlLAPStats Control calls, use 
  60.             NewIPIOCompletion to set up a IPIOCompletionUPP universal procptr
  61.             to pass in the ioCompletion field of the parameter block.
  62.         3. For TCPCreatePB Control calls, use NewTCPNotifyProc to set up a
  63.             TCPNotifyUPP universal procptr to pass in the notifyProc field
  64.             of the parameter block
  65.         4. For all of the TCP Control calls using the TCPiopb parameter block,
  66.             use NewTCPIOCompletionProc to set up a TCPIOCompletionUPP
  67.             universal procptr to pass in the ioCompletion field of the paramter
  68.             block.
  69.         5. For UDBCreatePB Control calls, use NewUDPNotifyProc to set up a
  70.             UDPNotifyUPP universal procptr to pass in the notifyProc field
  71.             of the parameter block
  72.         6. For all of the UDP Control calls using the UDPiopb parameter block,
  73.             use NewUDPIOCompletionProc to set up a UDPIOCompletionUPP
  74.             universal procptr to pass in the ioCompletion field of the paramter
  75.             block.
  76.         7. For all calls implementing a notifyProc or ioCompletion routine
  77.             which was set up using a NewTCPRoutineProc call, do not call
  78.             DisposeRoutineSDescriptor on the universal procptr until
  79.             after the completion or notify proc has completed.
  80. */
  81. /* MacTCP return Codes in the range -23000 through -23049 */
  82.  
  83. enum {
  84.     inProgress                    = 1,                            /* I/O in progress */
  85.     ipBadLapErr                    = -23000,                        /* bad network configuration */
  86.     ipBadCnfgErr                = -23001,                        /* bad IP configuration error */
  87.     ipNoCnfgErr                    = -23002,                        /* missing IP or LAP configuration error */
  88.     ipLoadErr                    = -23003,                        /* error in MacTCP load */
  89.     ipBadAddr                    = -23004,                        /* error in getting address */
  90.     connectionClosing            = -23005,                        /* connection is closing */
  91.     invalidLength                = -23006,
  92.     connectionExists            = -23007,                        /* request conflicts with existing connection */
  93.     connectionDoesntExist        = -23008,                        /* connection does not exist */
  94.     insufficientResources        = -23009,                        /* insufficient resources to perform request */
  95.     invalidStreamPtr            = -23010,
  96.     streamAlreadyOpen            = -23011,
  97.     connectionTerminated        = -23012,
  98.     invalidBufPtr                = -23013,
  99.     invalidRDS                    = -23014,
  100.     invalidWDS                    = -23014,
  101.     openFailed                    = -23015,
  102.     commandTimeout                = -23016,
  103.     duplicateSocket                = -23017
  104. };
  105.  
  106. /* Error codes from internal IP functions */
  107.  
  108. enum {
  109.     ipDontFragErr                = -23032,                        /* Packet too large to send w/o fragmenting */
  110.     ipDestDeadErr                = -23033,                        /* destination not responding */
  111.     icmpEchoTimeoutErr            = -23035,                        /* ICMP echo timed-out */
  112.     ipNoFragMemErr                = -23036,                        /* no memory to send fragmented pkt */
  113.     ipRouteErr                    = -23037,                        /* can't route packet off-net */
  114.     nameSyntaxErr                = -23041,
  115.     cacheFault                    = -23042,
  116.     noResultProc                = -23043,
  117.     noNameServer                = -23044,
  118.     authNameErr                    = -23045,
  119.     noAnsErr                    = -23046,
  120.     dnrErr                        = -23047,
  121.     outOfMemory                    = -23048
  122. };
  123.  
  124.  
  125. enum {
  126.     BYTES_16WORD                = 2,                            /* bytes per = 16, bit ip word */
  127.     BYTES_32WORD                = 4,                            /* bytes per = 32, bit ip word */
  128.     BYTES_64WORD                = 8                                /* bytes per = 64, bit ip word */
  129. };
  130.  
  131. /* 8-bit quantity */
  132. typedef UInt8 b_8;
  133. /* 16-bit quantity */
  134. typedef UInt16 b_16;
  135. /* 32-bit quantity */
  136. typedef UInt32 b_32;
  137. /* IP address is 32-bits */
  138. typedef b_32 ip_addr;
  139. struct ip_addrbytes {
  140.     union {
  141.         b_32                             addr;
  142.         UInt8                             byte[4];
  143.     }                                 a;
  144. };
  145. typedef struct ip_addrbytes ip_addrbytes;
  146.  
  147. struct wdsEntry {
  148.     unsigned short                     length;                        /* length of buffer */
  149.     Ptr                             ptr;                        /* pointer to buffer */
  150. };
  151. typedef struct wdsEntry wdsEntry;
  152.  
  153. struct rdsEntry {
  154.     unsigned short                     length;                        /* length of buffer */
  155.     Ptr                             ptr;                        /* pointer to buffer */
  156. };
  157. typedef struct rdsEntry rdsEntry;
  158.  
  159. typedef unsigned long BufferPtr;
  160. typedef unsigned long StreamPtr;
  161.  
  162. enum {
  163.     netUnreach                    = 0,
  164.     hostUnreach                    = 1,
  165.     protocolUnreach                = 2,
  166.     portUnreach                    = 3,
  167.     fragReqd                    = 4,
  168.     sourceRouteFailed            = 5,
  169.     timeExceeded                = 6,
  170.     parmProblem                    = 7,
  171.     missingOption                = 8,
  172.     lastICMPMsgType                = 32767
  173. };
  174.  
  175. typedef unsigned short ICMPMsgType;
  176. typedef b_16 ip_port;
  177. struct ICMPReport {
  178.     StreamPtr                         streamPtr;
  179.     ip_addr                         localHost;
  180.     ip_port                         localPort;
  181.     ip_addr                         remoteHost;
  182.     ip_port                         remotePort;
  183.     short                             reportType;
  184.     unsigned short                     optionalAddlInfo;
  185.     unsigned long                     optionalAddlInfoPtr;
  186. };
  187. typedef struct ICMPReport ICMPReport;
  188.  
  189. /* csCode to get our IP address */
  190.  
  191. enum {
  192.     ipctlGetAddr                = 15
  193. };
  194.  
  195. typedef struct GetAddrParamBlock GetAddrParamBlock;
  196. typedef void (*GetIPIOCompletionProcPtr)(GetAddrParamBlock *iopb);
  197.  
  198. #if GENERATINGCFM
  199. typedef UniversalProcPtr GetIPIOCompletionUPP;
  200. #else
  201. typedef GetIPIOCompletionProcPtr GetIPIOCompletionUPP;
  202. #endif
  203. struct GetAddrParamBlock {
  204.     QElem *                            qLink;
  205.     short                             qType;
  206.     short                             ioTrap;
  207.     Ptr                             ioCmdAddr;
  208.     GetIPIOCompletionUPP             ioCompletion;
  209.     OSErr                             ioResult;
  210.     StringPtr                         ioNamePtr;
  211.     short                             ioVRefNum;
  212.     short                             ioCRefNum;
  213.     short                             csCode;
  214.     ip_addr                         ourAddress;                    /* our IP address */
  215.     long                             ourNetMask;                    /* our IP net mask */
  216. };
  217.  
  218. /* control codes */
  219.  
  220. enum {
  221.     ipctlEchoICMP                = 17,                            /* send icmp echo */
  222.     ipctlLAPStats                = 19                            /* get lap stats */
  223. };
  224.  
  225. typedef struct ICMPParamBlock ICMPParamBlock;
  226. typedef void (*IPIOCompletionProcPtr)(ICMPParamBlock *iopb);
  227.  
  228. #if GENERATINGCFM
  229. typedef UniversalProcPtr IPIOCompletionUPP;
  230. #else
  231. typedef IPIOCompletionProcPtr IPIOCompletionUPP;
  232. #endif
  233. struct ICMPParamBlock {
  234.     QElem *                            qLink;
  235.     short                             qType;
  236.     short                             ioTrap;
  237.     Ptr                             ioCmdAddr;
  238.     IPIOCompletionUPP                 ioCompletion;
  239.     OSErr                             ioResult;
  240.     StringPtr                         ioNamePtr;
  241.     short                             ioVRefNum;
  242.     short                             ioCRefNum;
  243.     short                             csCode;
  244.     short                             params[11];
  245.     struct {
  246.         unsigned long                     echoRequestOut;            /* time in ticks of when the echo request went out */
  247.         unsigned long                     echoReplyIn;            /* time in ticks of when the reply was received */
  248.         rdsEntry                         echoedData;                /* data received in responce */
  249.         Ptr                             options;
  250.         unsigned long                     userDataPtr;
  251.     }                                 icmpEchoInfo;
  252. };
  253.  
  254. typedef void (*ICMPEchoNotifyProcPtr)(ICMPParamBlock *iopb);
  255.  
  256. #if GENERATINGCFM
  257. typedef UniversalProcPtr ICMPEchoNotifyUPP;
  258. #else
  259. typedef ICMPEchoNotifyProcPtr ICMPEchoNotifyUPP;
  260. #endif
  261. typedef struct LAPStats LAPStats;
  262. struct IPParamBlock {
  263.     QElem *                            qLink;
  264.     short                             qType;
  265.     short                             ioTrap;
  266.     Ptr                             ioCmdAddr;
  267.     IPIOCompletionUPP                 ioCompletion;
  268.     OSErr                             ioResult;
  269.     StringPtr                         ioNamePtr;
  270.     short                             ioVRefNum;
  271.     short                             ioCRefNum;
  272.     short                             csCode;
  273.     union {
  274.         struct {
  275.             ip_addr                         dest;                /* echo to IP address */
  276.             wdsEntry                         data;
  277.             short                             timeout;
  278.             Ptr                             options;
  279.             unsigned short                     optLength;
  280.             ICMPEchoNotifyUPP                 icmpCompletion;
  281.             unsigned long                     userDataPtr;
  282.         }                                 IPEchoPB;
  283.         struct {
  284.             LAPStats *                        lapStatsPtr;
  285.         }                                 LAPStatsPB;
  286.     }                                 csParam;
  287. };
  288. typedef struct IPParamBlock IPParamBlock;
  289.  
  290. struct nbp_entry {
  291.     ip_addr                         ip_address;                    /* IP address */
  292.     AddrBlock                         at_address;                    /* matching AppleTalk address */
  293.     Boolean                         gateway;                    /* TRUE if entry for a gateway */
  294.     Boolean                         valid;                        /* TRUE if LAP address is valid */
  295.     Boolean                         probing;                    /* TRUE if NBP lookup pending */
  296.     SInt8                             afiller;                    /* Filler for proper byte alignment     */
  297.     long                             age;                        /* ticks since cache entry verified */
  298.     long                             access;                        /* ticks since last access */
  299.     SInt8                             filler[116];                /* for internal use only !!! */
  300. };
  301. typedef struct nbp_entry nbp_entry;
  302.  
  303. struct Enet_addr {
  304.     b_16                             en_hi;
  305.     b_32                             en_lo;
  306. };
  307. typedef struct Enet_addr Enet_addr;
  308.  
  309. struct arp_entry {
  310.     short                             age;                        /* cache aging field */
  311.     b_16                             protocol;                    /* Protocol type */
  312.     ip_addr                         ip_address;                    /* IP address */
  313.     Enet_addr                         en_address;                    /* matching Ethernet address */
  314. };
  315. typedef struct arp_entry arp_entry;
  316.  
  317. union LAPStatsAddrXlation {
  318.     arp_entry *                        arp_table;
  319.     nbp_entry *                        nbp_table;
  320. };
  321. typedef union LAPStatsAddrXlation LAPStatsAddrXlation;
  322.  
  323. struct LAPStats {
  324.     short                             ifType;
  325.     char *                            ifString;
  326.     short                             ifMaxMTU;
  327.     long                             ifSpeed;
  328.     short                             ifPhyAddrLength;
  329.     char *                            ifPhysicalAddress;
  330.     LAPStatsAddrXlation             AddrXlation;
  331.     short                             slotNumber;
  332. };
  333.  
  334. /* number of ARP table entries */
  335.  
  336. enum {
  337.     ARP_TABLE_SIZE                = 20
  338. };
  339.  
  340.  
  341. enum {
  342.     NBP_TABLE_SIZE                = 20,                            /* number of NBP table entries */
  343.     NBP_MAX_NAME_SIZE            = 16 + 10 + 2
  344. };
  345.  
  346. /* Command codes */
  347.  
  348. enum {
  349.     TCPCreate                    = 30,
  350.     TCPPassiveOpen                = 31,
  351.     TCPActiveOpen                = 32,
  352.     TCPSend                        = 34,
  353.     TCPNoCopyRcv                = 35,
  354.     TCPRcvBfrReturn                = 36,
  355.     TCPRcv                        = 37,
  356.     TCPClose                    = 38,
  357.     TCPAbort                    = 39,
  358.     TCPStatus                    = 40,
  359.     TCPExtendedStat                = 41,
  360.     TCPRelease                    = 42,
  361.     TCPGlobalInfo                = 43,
  362.     TCPCtlMax                    = 49
  363. };
  364.  
  365.  
  366. enum {
  367.     TCPClosing                    = 1,
  368.     TCPULPTimeout                = 2,
  369.     TCPTerminate                = 3,
  370.     TCPDataArrival                = 4,
  371.     TCPUrgent                    = 5,
  372.     TCPICMPReceived                = 6,
  373.     lastEvent                    = 32767
  374. };
  375.  
  376. typedef unsigned short TCPEventCode;
  377.  
  378. enum {
  379.     TCPRemoteAbort                = 2,
  380.     TCPNetworkFailure            = 3,
  381.     TCPSecPrecMismatch            = 4,
  382.     TCPULPTimeoutTerminate        = 5,
  383.     TCPULPAbort                    = 6,
  384.     TCPULPClose                    = 7,
  385.     TCPServiceError                = 8,
  386.     lastReason                    = 32767
  387. };
  388.  
  389. typedef unsigned short TCPTerminationReason;
  390. typedef pascal void (*TCPNotifyProcPtr)(StreamPtr tcpStream, unsigned short eventCode, Ptr userDataPtr, unsigned short terminReason, ICMPReport *icmpMsg);
  391.  
  392. #if GENERATINGCFM
  393. typedef UniversalProcPtr TCPNotifyUPP;
  394. #else
  395. typedef TCPNotifyProcPtr TCPNotifyUPP;
  396. #endif
  397. typedef unsigned short tcp_port;
  398. /* ValidityFlags */
  399.  
  400. enum {
  401.     timeoutValue                = 0x80,
  402.     timeoutAction                = 0x40,
  403.     typeOfService                = 0x20,
  404.     precedence                    = 0x10
  405. };
  406.  
  407. /* TOSFlags */
  408.  
  409. enum {
  410.     lowDelay                    = 0x01,
  411.     throughPut                    = 0x02,
  412.     reliability                    = 0x04
  413. };
  414.  
  415. struct TCPCreatePB {
  416.     Ptr                             rcvBuff;
  417.     unsigned long                     rcvBuffLen;
  418.     TCPNotifyUPP                     notifyProc;
  419.     Ptr                             userDataPtr;
  420. };
  421. typedef struct TCPCreatePB TCPCreatePB;
  422.  
  423. struct TCPOpenPB {
  424.     SInt8                             ulpTimeoutValue;
  425.     SInt8                             ulpTimeoutAction;
  426.     SInt8                             validityFlags;
  427.     SInt8                             commandTimeoutValue;
  428.     ip_addr                         remoteHost;
  429.     tcp_port                         remotePort;
  430.     ip_addr                         localHost;
  431.     tcp_port                         localPort;
  432.     SInt8                             tosFlags;
  433.     SInt8                             precedence;
  434.     Boolean                         dontFrag;
  435.     SInt8                             timeToLive;
  436.     SInt8                             security;
  437.     SInt8                             optionCnt;
  438.     SInt8                             options[40];
  439.     Ptr                             userDataPtr;
  440. };
  441. typedef struct TCPOpenPB TCPOpenPB;
  442.  
  443. struct TCPSendPB {
  444.     SInt8                             ulpTimeoutValue;
  445.     SInt8                             ulpTimeoutAction;
  446.     SInt8                             validityFlags;
  447.     Boolean                         pushFlag;
  448.     Boolean                         urgentFlag;
  449.     SInt8                             filler;                        /* Filler for proper byte alignment     */
  450.     Ptr                             wdsPtr;
  451.     unsigned long                     sendFree;
  452.     unsigned short                     sendLength;
  453.     Ptr                             userDataPtr;
  454. };
  455. typedef struct TCPSendPB TCPSendPB;
  456.  
  457. /* for receive and return rcv buff calls */
  458. /*   Note: the filler in the following structure is in a different location than */
  459. /*         that specified in the Programmer's Guide.  */
  460. struct TCPReceivePB {
  461.     SInt8                             commandTimeoutValue;
  462.     Boolean                         markFlag;
  463.     Boolean                         urgentFlag;
  464.     SInt8                             filler;                        /* Filler for proper byte alignment  */
  465.     Ptr                             rcvBuff;
  466.     unsigned short                     rcvBuffLen;
  467.     Ptr                             rdsPtr;
  468.     unsigned short                     rdsLength;
  469.     unsigned short                     secondTimeStamp;
  470.     Ptr                             userDataPtr;
  471. };
  472. typedef struct TCPReceivePB TCPReceivePB;
  473.  
  474. struct TCPClosePB {
  475.     SInt8                             ulpTimeoutValue;
  476.     SInt8                             ulpTimeoutAction;
  477.     SInt8                             validityFlags;
  478.     SInt8                             filler;                        /* Filler for proper byte alignment     */
  479.     Ptr                             userDataPtr;
  480. };
  481. typedef struct TCPClosePB TCPClosePB;
  482.  
  483. struct HistoBucket {
  484.     unsigned short                     value;
  485.     unsigned long                     counter;
  486. };
  487. typedef struct HistoBucket HistoBucket;
  488.  
  489.  
  490. enum {
  491.     NumOfHistoBuckets            = 7
  492. };
  493.  
  494. struct TCPConnectionStats {
  495.     unsigned long                     dataPktsRcvd;
  496.     unsigned long                     dataPktsSent;
  497.     unsigned long                     dataPktsResent;
  498.     unsigned long                     bytesRcvd;
  499.     unsigned long                     bytesRcvdDup;
  500.     unsigned long                     bytesRcvdPastWindow;
  501.     unsigned long                     bytesSent;
  502.     unsigned long                     bytesResent;
  503.     unsigned short                     numHistoBuckets;
  504.     HistoBucket                     sentSizeHisto[7];
  505.     unsigned short                     lastRTT;
  506.     unsigned short                     tmrSRTT;
  507.     unsigned short                     rttVariance;
  508.     unsigned short                     tmrRTO;
  509.     SInt8                             sendTries;
  510.     SInt8                             sourchQuenchRcvd;
  511. };
  512. typedef struct TCPConnectionStats TCPConnectionStats;
  513.  
  514. struct TCPStatusPB {
  515.     SInt8                             ulpTimeoutValue;
  516.     SInt8                             ulpTimeoutAction;
  517.     long                             unused;
  518.     ip_addr                         remoteHost;
  519.     tcp_port                         remotePort;
  520.     ip_addr                         localHost;
  521.     tcp_port                         localPort;
  522.     SInt8                             tosFlags;
  523.     SInt8                             precedence;
  524.     SInt8                             connectionState;
  525.     SInt8                             filler;                        /* Filler for proper byte alignment     */
  526.     unsigned short                     sendWindow;
  527.     unsigned short                     rcvWindow;
  528.     unsigned short                     amtUnackedData;
  529.     unsigned short                     amtUnreadData;
  530.     Ptr                             securityLevelPtr;
  531.     unsigned long                     sendUnacked;
  532.     unsigned long                     sendNext;
  533.     unsigned long                     congestionWindow;
  534.     unsigned long                     rcvNext;
  535.     unsigned long                     srtt;
  536.     unsigned long                     lastRTT;
  537.     unsigned long                     sendMaxSegSize;
  538.     TCPConnectionStats *            connStatPtr;
  539.     Ptr                             userDataPtr;
  540. };
  541. typedef struct TCPStatusPB TCPStatusPB;
  542.  
  543. struct TCPAbortPB {
  544.     Ptr                             userDataPtr;
  545. };
  546. typedef struct TCPAbortPB TCPAbortPB;
  547.  
  548. struct TCPParam {
  549.     unsigned long                     tcpRtoA;
  550.     unsigned long                     tcpRtoMin;
  551.     unsigned long                     tcpRtoMax;
  552.     unsigned long                     tcpMaxSegSize;
  553.     unsigned long                     tcpMaxConn;
  554.     unsigned long                     tcpMaxWindow;
  555. };
  556. typedef struct TCPParam TCPParam;
  557.  
  558. struct TCPStats {
  559.     unsigned long                     tcpConnAttempts;
  560.     unsigned long                     tcpConnOpened;
  561.     unsigned long                     tcpConnAccepted;
  562.     unsigned long                     tcpConnClosed;
  563.     unsigned long                     tcpConnAborted;
  564.     unsigned long                     tcpOctetsIn;
  565.     unsigned long                     tcpOctetsOut;
  566.     unsigned long                     tcpOctetsInDup;
  567.     unsigned long                     tcpOctetsRetrans;
  568.     unsigned long                     tcpInputPkts;
  569.     unsigned long                     tcpOutputPkts;
  570.     unsigned long                     tcpDupPkts;
  571.     unsigned long                     tcpRetransPkts;
  572. };
  573. typedef struct TCPStats TCPStats;
  574.  
  575. typedef StreamPtr *StreamPPtr;
  576. struct TCPGlobalInfoPB {
  577.     TCPParam *                        tcpParamPtr;
  578.     TCPStats *                        tcpStatsPtr;
  579.     StreamPPtr                         tcpCDBTable[1];
  580.     Ptr                             userDataPtr;
  581.     unsigned short                     maxTCPConnections;
  582. };
  583. typedef struct TCPGlobalInfoPB TCPGlobalInfoPB;
  584.  
  585. typedef struct TCPiopb TCPiopb;
  586. typedef void (*TCPIOCompletionProcPtr)(TCPiopb *iopb);
  587.  
  588. #if GENERATINGCFM
  589. typedef UniversalProcPtr TCPIOCompletionUPP;
  590. #else
  591. typedef TCPIOCompletionProcPtr TCPIOCompletionUPP;
  592. #endif
  593. struct TCPiopb {
  594.     SInt8                             fill12[12];
  595.     TCPIOCompletionUPP                 ioCompletion;
  596.     short                             ioResult;
  597.     Ptr                             ioNamePtr;
  598.     short                             ioVRefNum;
  599.     short                             ioCRefNum;
  600.     short                             csCode;
  601.     StreamPtr                         tcpStream;
  602.     union {
  603.         TCPCreatePB                     create;
  604.         TCPOpenPB                         open;
  605.         TCPSendPB                         send;
  606.         TCPReceivePB                     receive;
  607.         TCPClosePB                         close;
  608.         TCPAbortPB                         abort;
  609.         TCPStatusPB                     status;
  610.         TCPGlobalInfoPB                 globalInfo;
  611.     }                                 csParam;
  612. };
  613.  
  614.  
  615. enum {
  616.     UDPCreate                    = 20,
  617.     UDPRead                        = 21,
  618.     UDPBfrReturn                = 22,
  619.     UDPWrite                    = 23,
  620.     UDPRelease                    = 24,
  621.     UDPMaxMTUSize                = 25,
  622.     UDPStatus                    = 26,
  623.     UDPMultiCreate                = 27,
  624.     UDPMultiSend                = 28,
  625.     UDPMultiRead                = 29,
  626.     UDPCtlMax                    = 29
  627. };
  628.  
  629.  
  630. enum {
  631.     UDPDataArrival                = 1,
  632.     UDPICMPReceived                = 2,
  633.     lastUDPEvent                = 32767
  634. };
  635.  
  636. typedef unsigned short UDPEventCode;
  637. typedef pascal void (*UDPNotifyProcPtr)(StreamPtr udpStream, unsigned short eventCode, Ptr userDataPtr, ICMPReport *icmpMsg);
  638.  
  639. #if GENERATINGCFM
  640. typedef UniversalProcPtr UDPNotifyUPP;
  641. #else
  642. typedef UDPNotifyProcPtr UDPNotifyUPP;
  643. #endif
  644. typedef unsigned short udp_port;
  645. /* for create and release calls */
  646. struct UDPCreatePB {
  647.     Ptr                             rcvBuff;
  648.     unsigned long                     rcvBuffLen;
  649.     UDPNotifyUPP                     notifyProc;
  650.     unsigned short                     localPort;
  651.     Ptr                             userDataPtr;
  652.     udp_port                         endingPort;
  653. };
  654. typedef struct UDPCreatePB UDPCreatePB;
  655.  
  656. struct UDPSendPB {
  657.     unsigned short                     reserved;
  658.     ip_addr                         remoteHost;
  659.     udp_port                         remotePort;
  660.     Ptr                             wdsPtr;
  661.     Boolean                         checkSum;
  662.     SInt8                             filler;                        /* Filler for proper byte alignment     */
  663.     unsigned short                     sendLength;
  664.     Ptr                             userDataPtr;
  665.     udp_port                         localPort;
  666. };
  667. typedef struct UDPSendPB UDPSendPB;
  668.  
  669. /* for receive and buffer return calls */
  670. struct UDPReceivePB {
  671.     unsigned short                     timeOut;
  672.     ip_addr                         remoteHost;
  673.     udp_port                         remotePort;
  674.     Ptr                             rcvBuff;
  675.     unsigned short                     rcvBuffLen;
  676.     unsigned short                     secondTimeStamp;
  677.     Ptr                             userDataPtr;
  678.     ip_addr                         destHost;                    /* only for use with multi rcv */
  679.     udp_port                         destPort;                    /* only for use with multi rcv */
  680. };
  681. typedef struct UDPReceivePB UDPReceivePB;
  682.  
  683. struct UDPMTUPB {
  684.     unsigned short                     mtuSize;
  685.     ip_addr                         remoteHost;
  686.     Ptr                             userDataPtr;
  687. };
  688. typedef struct UDPMTUPB UDPMTUPB;
  689.  
  690. typedef struct UDPiopb UDPiopb;
  691. typedef void (*UDPIOCompletionProcPtr)(UDPiopb *iopb);
  692.  
  693. #if GENERATINGCFM
  694. typedef UniversalProcPtr UDPIOCompletionUPP;
  695. #else
  696. typedef UDPIOCompletionProcPtr UDPIOCompletionUPP;
  697. #endif
  698. struct UDPiopb {
  699.     SInt8                             fill12[12];
  700.     UDPIOCompletionUPP                 ioCompletion;
  701.     short                             ioResult;
  702.     Ptr                             ioNamePtr;
  703.     short                             ioVRefNum;
  704.     short                             ioCRefNum;
  705.     short                             csCode;
  706.     StreamPtr                         udpStream;
  707.     union {
  708.         UDPCreatePB                     create;
  709.         UDPSendPB                         send;
  710.         UDPReceivePB                     receive;
  711.         UDPMTUPB                         mtu;
  712.     }                                 csParam;
  713. };
  714.  
  715.  
  716. #if GENERATINGCFM
  717. #else
  718. #endif
  719.  
  720. enum {
  721.     uppGetIPIOCompletionProcInfo = kCStackBased
  722.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(GetAddrParamBlock *))),
  723.     uppIPIOCompletionProcInfo = kCStackBased
  724.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ICMPParamBlock *))),
  725.     uppICMPEchoNotifyProcInfo = kCStackBased
  726.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ICMPParamBlock *))),
  727.     uppTCPNotifyProcInfo = kPascalStackBased
  728.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(StreamPtr)))
  729.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(unsigned short)))
  730.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Ptr)))
  731.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(unsigned short)))
  732.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(ICMPReport *))),
  733.     uppTCPIOCompletionProcInfo = kCStackBased
  734.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(TCPiopb *))),
  735.     uppUDPNotifyProcInfo = kPascalStackBased
  736.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(StreamPtr)))
  737.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(unsigned short)))
  738.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Ptr)))
  739.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(ICMPReport *))),
  740.     uppUDPIOCompletionProcInfo = kCStackBased
  741.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(UDPiopb *)))
  742. };
  743.  
  744. #if GENERATINGCFM
  745. #define NewGetIPIOCompletionProc(userRoutine)        \
  746.         (GetIPIOCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetIPIOCompletionProcInfo, GetCurrentArchitecture())
  747. #define NewIPIOCompletionProc(userRoutine)        \
  748.         (IPIOCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppIPIOCompletionProcInfo, GetCurrentArchitecture())
  749. #define NewICMPEchoNotifyProc(userRoutine)        \
  750.         (ICMPEchoNotifyUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppICMPEchoNotifyProcInfo, GetCurrentArchitecture())
  751. #define NewTCPNotifyProc(userRoutine)        \
  752.         (TCPNotifyUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTCPNotifyProcInfo, GetCurrentArchitecture())
  753. #define NewTCPIOCompletionProc(userRoutine)        \
  754.         (TCPIOCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTCPIOCompletionProcInfo, GetCurrentArchitecture())
  755. #define NewUDPNotifyProc(userRoutine)        \
  756.         (UDPNotifyUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppUDPNotifyProcInfo, GetCurrentArchitecture())
  757. #define NewUDPIOCompletionProc(userRoutine)        \
  758.         (UDPIOCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppUDPIOCompletionProcInfo, GetCurrentArchitecture())
  759. #else
  760. #define NewGetIPIOCompletionProc(userRoutine)        \
  761.         ((GetIPIOCompletionUPP) (userRoutine))
  762. #define NewIPIOCompletionProc(userRoutine)        \
  763.         ((IPIOCompletionUPP) (userRoutine))
  764. #define NewICMPEchoNotifyProc(userRoutine)        \
  765.         ((ICMPEchoNotifyUPP) (userRoutine))
  766. #define NewTCPNotifyProc(userRoutine)        \
  767.         ((TCPNotifyUPP) (userRoutine))
  768. #define NewTCPIOCompletionProc(userRoutine)        \
  769.         ((TCPIOCompletionUPP) (userRoutine))
  770. #define NewUDPNotifyProc(userRoutine)        \
  771.         ((UDPNotifyUPP) (userRoutine))
  772. #define NewUDPIOCompletionProc(userRoutine)        \
  773.         ((UDPIOCompletionUPP) (userRoutine))
  774. #endif
  775.  
  776. #if GENERATINGCFM
  777. #define CallGetIPIOCompletionProc(userRoutine, iopb)        \
  778.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppGetIPIOCompletionProcInfo, (iopb))
  779. #define CallIPIOCompletionProc(userRoutine, iopb)        \
  780.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppIPIOCompletionProcInfo, (iopb))
  781. #define CallICMPEchoNotifyProc(userRoutine, iopb)        \
  782.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppICMPEchoNotifyProcInfo, (iopb))
  783. #define CallTCPNotifyProc(userRoutine, tcpStream, eventCode, userDataPtr, terminReason, icmpMsg)        \
  784.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppTCPNotifyProcInfo, (tcpStream), (eventCode), (userDataPtr), (terminReason), (icmpMsg))
  785. #define CallTCPIOCompletionProc(userRoutine, iopb)        \
  786.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppTCPIOCompletionProcInfo, (iopb))
  787. #define CallUDPNotifyProc(userRoutine, udpStream, eventCode, userDataPtr, icmpMsg)        \
  788.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppUDPNotifyProcInfo, (udpStream), (eventCode), (userDataPtr), (icmpMsg))
  789. #define CallUDPIOCompletionProc(userRoutine, iopb)        \
  790.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppUDPIOCompletionProcInfo, (iopb))
  791. #else
  792. #define CallGetIPIOCompletionProc(userRoutine, iopb)        \
  793.         (*(userRoutine))((iopb))
  794. #define CallIPIOCompletionProc(userRoutine, iopb)        \
  795.         (*(userRoutine))((iopb))
  796. #define CallICMPEchoNotifyProc(userRoutine, iopb)        \
  797.         (*(userRoutine))((iopb))
  798. #define CallTCPNotifyProc(userRoutine, tcpStream, eventCode, userDataPtr, terminReason, icmpMsg)        \
  799.         (*(userRoutine))((tcpStream), (eventCode), (userDataPtr), (terminReason), (icmpMsg))
  800. #define CallTCPIOCompletionProc(userRoutine, iopb)        \
  801.         (*(userRoutine))((iopb))
  802. #define CallUDPNotifyProc(userRoutine, udpStream, eventCode, userDataPtr, icmpMsg)        \
  803.         (*(userRoutine))((udpStream), (eventCode), (userDataPtr), (icmpMsg))
  804. #define CallUDPIOCompletionProc(userRoutine, iopb)        \
  805.         (*(userRoutine))((iopb))
  806. #endif
  807. #endif
  808.  
  809. #if PRAGMA_ALIGN_SUPPORTED
  810. #pragma options align=reset
  811. #endif
  812.  
  813. #if PRAGMA_IMPORT_SUPPORTED
  814. #pragma import off
  815. #endif
  816.  
  817. #ifdef __cplusplus
  818. }
  819. #endif
  820.  
  821. #endif /* __MACTCP__ */
  822.  
  823.